package com.bo.threadMethod;

/**
 * @Author: gpb
 * @Date: 2024/7/14 10:32
 * @Description:
 */
public class ThreadYield {
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                System.out.println("t1:" + i);
                if (i == 50) {
                    Thread.yield();
                    System.out.println("t1 yield");
                }
            }
        });
        Thread t2 = new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                System.out.println("t2:" + i);
            }
        });
        t2.start();
        t1.start();
    }
}
